function input_click_css() {
    $("#bl_div .text").click(function() {
        $(this).css("border-color", "#BFCFE0");
    }), $("#bl_div .text").blur(function() {
        $(this).css("border-color", "#D6D6D6");
    });
    var a = Date.parse(new Date);
    a /= 1e3, $.ajax({
        "type": "post",
        "url": zdmya_site_domain + "/wp-content/plugins/hotinfor/html/check_email_div.php",
        "data": "nowtime=" + a,
        "success": function(b) {
            b == 1 ? $("#bl_email_div").css("display", "none") : $("#bl_email_div").css("display", "block");
        }
    });
}

function add_tr_more_item_link() {
    return now_row = parseInt(link_total), link_total < more_link_limit_num && link_total >= 1 ? (link_total += 1, $('<div class="wantItem"><div class="titleItem">链接：</div><div class="perDataItem" style="position:relative;"><input type="text" class="inputBox text" id="un-more-item-link[]" name="more_item_link[]" /><input type="button" class="adel" onclick="adel(this)" style="cursor:pointer; width:30px; right:0px; top:5px; position:absolute;" value="-" title="删除链接" /></div><div class="clear"></div></div>').insertAfter($("#bl_div div.wantItem:eq(" + now_row + ")"))) : alert("对不起，链接最多为" + more_link_limit_num + "个！"), !1;
}

function adel(b) {
    var a = b.parentNode.parentNode.parentNode;
    a.removeChild(b.parentNode.parentNode), link_total -= 1;
}

function dodiv(a) {
    $("#sub_tr").css("display", ""), a == "zztj" ? ($("#un-item-reason-url").css("display", ""), $("#item_reason_other").attr("checked", "checked")) : a == "yctj" && ($("#un-item-reason-url").css("display", "none"), $("#item_reason_b2c").attr("checked", "checked")), $(".text").removeClass("error-border"), $("#sub-error").html("");
}

function sucBoxhide() {
    $(".blSuccessBox").css("display", "none");
}

function choose_bug_type(a) {
    return 1 == a ? ($(".itemLinkRecovery").css("display", "none"), $("input:radio[id='item_bug_type_propose']").attr("checked", "checked")) : 2 == a ? ($("input:radio[id='item_bug_type_recovery']").attr("checked", "checked"), $(".itemLinkRecovery").removeAttr("style")) : 3 == a && ($(".itemLinkRecovery").css("display", "none"), $("input:radio[id='item_bug_type_bug']").attr("checked", "checked")), $(".text").removeClass("error-border"), !1;
}

function init_js_datepicker() {
    var a = new Date;
    $("#un-activity-end-time").datetimepicker({
        "dateFormat": "yy-mm-dd",
        "timeFormat": "HH:mm",
        "minDateTime": new Date(a.getTime())
    });
}

function dogodprice(a) {
    return a ? $("input:radio[id='item_is_god_price']").attr("checked", "checked") : $("input:radio[id='item_isnot_god_price']").attr("checked", "checked"), !1;
}

function remove_html_value(a) {
    $("#" + a).val("");
    return;
}

jQuery(function($) {
    function UsernoiseButton() {
        var self = this, $button = $('<a href="#" id="un-button" />').appendTo($("body")), property;
        $button.text(usernoise.buttonText), $button.addClass(usernoise.buttonClass), $button.attr("style", usernoise.buttonStyle), $button.click(function() {
            return usernoise.window.show(), !1;
        }), $.browser.msie && $.browser.version == "7.0" ? $button.addClass("ie7") : $.browser.msie && $.browser.version == "8.0" ? $button.addClass("ie8") : $button.addClass("css3"), ($button.is(".un-bottom") || $button.is(".un-top")) && $button.css("margin-left", "-" + $("#un-button").width() / 2 + "px"), $button.is(".un-left") ? property = "left" : $button.is(".un-right") ? property = "right" : $button.is(".un-bottom") ? property = "bottom" : property = "top", $button.is(".un-right.css3, .un-left.css3") && $button.css("margin-top", "-" + $button.width() + "px");
        var propOnStart = {}, propOnIn = {
            "opacity": 1
        }, propOnOut = {
            "opacity": .96
        };
        propOnStart[property] = "+=40px", propOnIn[property] = "+=3px", propOnOut[property] = "-=3px", $button.css("display", "block").animate(propOnStart).hover(function() {
            $button.animate(propOnIn, 100);
        }, function() {
            $button.animate(propOnOut, 100);
        });
    }
    function FeedbackForm($wrapper) {
        function selectTypeHandler() {
            var $selector = $(this).parent();
            $selector.find("a").removeClass("selected"), $(this).addClass("selected");
            var type = $(this).attr("id").replace("un-type-", "");
            return $selector.find("input[type=hidden]").val(type), $(document).trigger("typeselected#feedbackform#window.un", type), !1;
        }
        function submitHandler() {
            $(".text").removeClass("error-border");
            var data = $form.unSerializeObject();
            if($("#title").val()=="此处填写商品名称+最终价格" || $("#title").val()==""){
            	$("#sub-error").html("请填写标题!");
            	return false;
            }
            if($("#url").val()=="此处填写商品购买链接或活动地址" || $("#url").val()==""){
            	$("#sub-error").html("请填写链接!");
            	return false;
            }
            if($("#summary").val()==""){
            	$("#sub-error").html("请填写简介!");
            	return false;
            }
            if($("#checkcode").val()==""){
            	$("#sub-error").html("请填写验证码!");
            	return false;
            }
            return $(document).trigger("submitting#feedbackform#window.un", data), self.lock(), $form.find(".loader").show(), self.errors.hide(), $.post($form.attr("action"), data, function(response) {
                $form.find(".loader").hide(), self.unlock(), response = usernoise.helpers.parseJSON(response);
                if (response.result == 'ok') {
                	$("#title").val("");
                    $("#url").val("");
                    $("#summary").val("");
                	$("#sub-error").html("提交成功!");
                } else response.success == 0 ? $("#sub-error").html("提交失败，请刷新重试!") : ($(response.errors).each(function(index, error) {
                    $("#un-" + error).addClass("error-border");
                }), $("#sub-error").html(response.result));                
                $("#checkcode").val("");
                document.getElementById('captcha_img').src='/checkcode.vm?'+Math.random();
                document.getElementById('checkcode').focus();
            }), !1;
            
        }
        var self = this, $wrapper = $wrapper, $form = $wrapper.find(".un-feedback-form");
        $form.find(".text").unAutoPlaceholder(), $form.attr("action", $form.attr("data-action")), $form.submit(submitHandler), $.extend(self, {
            "unlock": function() {
                $(document).trigger("unlocking#feedbackform#window.un"), $form.find("input, select, textarea").removeAttr("disabled"), $form.find(".un-types-wrapper a").click(selectTypeHandler);
            },
            "lock": function() {
                $form.find("*").unbind("click"), $(document).trigger("locking#feedbackform#window.un"), $form.find("input, select, textarea").attr("disabled", "disabled");
            },
            "errors": new Errors($form.find(".un-errors-wrapper"))
        }), $(document).trigger("created#feedbackform#window.un", self);
    }
    function Errors($errors) {
        var self = this, $errorsWrapper = $errors, $errors = $errorsWrapper.find(".un-errors");
        $.extend(self, {
            "show": function(errors) {
                $(errors).each(function(index, error) {
                    $errors.append($("<p />").text(error));
                }), $errorsWrapper.fadeIn("fast");
            },
            "hide": function(errors) {
                $errorsWrapper.fadeOut("fast", function() {
                    $errors.html(""), $errorsWrapper.hide();
                });
            },
            "showx": function(msg) {
                $errors.append(msg), $errorsWrapper.fadeIn("fast");
            }
        });
    }
    function ThankYouScreen($screen) {
        var self = this, $screen = $screen;
        $.extend(self, {
            "show": function(html) {
                $(".content").append($(html)), $("#un-reset-feedback").click(function() {
                    return $(document).trigger("close#window.un"), !1;
                });
            }
        });
    }
    function UsernoiseWindow(windowSelector) {
        function detectBrowser() {
            if (!$("#facebox").hasClass("un")) return;
            $("#facebox").addClass("un"), $.browser.msie && $.browser.version == "7.0" && $("#facebox").addClass("un-ie7"), $.browser.msie && $.browser.version == "8.0" && $("#facebox").addClass("un-ie8");
        }
        function showThankYouHandler(event, html) {
            self.thankYouScreen = new ThankYouScreen($window.find(".thank-you-screen")), self.thankYouScreen.show(html);
        }
        function initFacebox() {
            faceboxSettingsBackup = $.facebox.settings, $.facebox.settings = $.extend({}, $.facebox.settings), $.extend($.facebox.settings, {
                "closeImage": usernoise.closeImageUrl,
                "opacity": "0.6",
                "loadingImage": usernoise.ajaxLoaderUrl,
                "faceboxHtml": '		<div id="facebox" style="display:none;"> 		  <div class="popup"> 		    <div class="content"> 		    </div> 		    <a href="#" class="close"><img src="" title="close" class="close_image" /></a> 		  </div> 		</div>'
            });
        }
        var self = this, $window, windowHTML, faceboxSettingsBackup;
        $.extend(self, {
            "show": function() {
                initFacebox(), $.facebox($(windowHTML)), $("#facebox").addClass("un"), $window = $(windowSelector), self.feedbackForm = new FeedbackForm($window.find("#bl_div")), $(document).bind("loading.facebox", detectBrowser), $(document).bind("afterClose.facebox", function() {
                    self.remove();
                }), $(document).trigger("shown#window.un"), $(document).trigger("show#window.un");
            },
            "close": function() {
                $(document).trigger("close.facebox");
            },
            "remove": function() {
                $.facebox.settings = faceboxSettingsBackup, $("#facebox").removeClass("un").removeClass("un-ie7").removeClass("un-ie8"), $window.remove();
            }
        });
    }
    $("#facebox").is(":visible") && $("#facebox, #facebox_overlay, #un-button").hide().remove(), $.fn.unAutoPlaceholder = function() {
        $(this).each(function() {
            $(this).attr("data-default", $(this).val()), $(this).focus(function() {
                $(this).val() == $(this).attr("data-default") && ($(this).val(""), $(this).addClass("text-normal"), $(this).removeClass("text-empty"));
            }), $(this).blur(function() {
                $(this).val() == "" && ($(this).val($(this).attr("data-default")), $(this).removeClass("text-normal"), $(this).addClass("text-empty"));
            });
        });
    }, $.fn.unSerializeObject = function() {
        var o = {}, a = this.serializeArray();
        return $.each(a, function() {
            o[this.name] ? (o[this.name].push || (o[this.name] = [ o[this.name] ]), o[this.name].push(this.value || "")) : o[this.name] = this.value || "";
        }), o;
    }, usernoise.helpers = {
        "parseJSON": function(json) {
            return $.parseJSON ? $.parseJSON(json) : eval("(" + json + ")");
        }
    }, usernoise.feedbackForm = new FeedbackForm($("#bl_div"));
});

var more_link_limit_num = 5, link_total = 1;